package com.ambimmort.shj.action.generalfile;

import cn.net.greenet.common.db_service.ConfigManager;
import cn.net.greenet.generalfile.logic.GeneralFileProcess;
import com.ambimmort.shj.service.generalfile.Del_WhiteService;
import com.ambimmort.shj.service.generalfile.GetApp2DBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by 师梁 on 2015/7/30.
 */
@RequestMapping("/action/common/read_app.do")
public class GetApp2DB {
    @Autowired
    private GetApp2DBService getApp2DBService;

    @RequestMapping("/action/common/read_app.do")
    @ResponseBody
    public  boolean get(
            HttpServletRequest request, @RequestParam("path") String path,  @RequestParam("MessageType")String MessageType, @RequestParam("policy_instance")String policy_instance

    ){
        GeneralFileProcess pro = new GeneralFileProcess(path, MessageType, policy_instance);
        String name = ConfigManager.getInstance().getString("appFileName");
        path = pro.saveFile(request, name);
        try {

            return  getApp2DBService.get(path,MessageType,policy_instance,pro);

        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return false;
        }
    }
}
